package com.cyh.nio;

import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.channels.FileChannel;

/**
 * 读文件内容
 * */
public class BufferDemo02 {

    public static void main(String[] args) throws Exception {
        IntBuffer buffer = IntBuffer.allocate(8);
        for(int i = 0; i < buffer.capacity(); i++) {
            int j = 2 * (i + 1);
            buffer.put(j);
        }

        buffer.flip();

        while (buffer.hasRemaining()) {
            int j = buffer.get();
            System.out.println(j);
        }
    }
}
